#ifndef SERIAL_C_0a23c300_55e3_4b47_bce4_fe81e410e939
#define SERIAL_C_0a23c300_55e3_4b47_bce4_fe81e410e939

/*
**
** Copyright (c) 2010 by Lorimark Solutions, LLC.
** All Rights Reserved.
** Send inquiries to: info@lorimarksolutions.com
**
*/

#include <evie-systems.h>
#include <util/delay.h>

#include <megaserial.h>

#include <crc8.h>

uint8 rxGet(uint8 channel)
{
  uint8 retVal = 5;

  /*
  ** Wait some number of milliseconds for a character.
  **  If we don't get one then we'll be returning
  **  nothing.
  **
  */
  while( !rxUsartCount(channel) && retVal-- )
    _delay_ms(1);

  retVal = rxUsartGet(channel);

  ENABLE_INTERRUPTS;

  crc8( retVal );

  return( retVal );

}

void rxClear(uint8 channel)
{
  while( rxUsartCount(channel) )
  {
    rxUsartGet(channel);
    ENABLE_INTERRUPTS;
  }
}

void txPut( uint8 channel, uint8 data )
{
  txUsartPut( channel, data );
  ENABLE_INTERRUPTS;
  crc8( data );
}



#endif // end#ifndef SERIAL_C_0a23c300_55e3_4b47_bce4_fe81e410e939

